home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Windows Selection / Windows Selection 1.iso / Graphics / Formula Graphics Multimedia System / BITMAPS.SXT < prev    next >
Encoding:
Text File  |  1996-03-03  |  2.4 KB  |  78 lines

  1. //////////////////////////
  2. // Harrow Software 1996
  3. // Bitmap examples
  4.  
  5. ///////////////////////////
  6. // (1) - Loading a bitmap
  7.  
  8. // The following instruction will load a bitmap from disk
  9. //  and assign it to the "my_bitmap" handle. The bitmap object
  10. //  contains the bits of the image, its palette, and its resolution
  11.  
  12. load "example.gif" bitmap my_bitmap
  13.  
  14. message "width = ", my_bitmap.xlen            // bitmap width
  15. message "height = ", my_bitmap.ylen            // bitmap height
  16. switch my_bitmap.mode                        // color mode
  17.     case PAL
  18.         message "colors = 256"
  19.     case RGB16
  20.         message "colors = 65536"
  21.     case RGB24
  22.         message "colors = 24 million"
  23.  
  24. // The palette returned from the bitmap object will be a
  25. //  2 dimensional array of the form [256][3]
  26.  
  27. my_palette = @my_bitmap.palette                    // bitmap palette
  28. message "palette[0] = ",my_palette[0][0],",",my_palette[0][1],",",my_palette[0][2]
  29.  
  30. //////////////////////////////
  31. // (2) - Displaying a bitmap
  32.  
  33. // Bitmaps without palettes are easy to display. If the bitmap
  34. //  does have a palette and if you wish to display it with its
  35. //  full palette
  36.  
  37. display bitmap my_bitmap
  38.  
  39. // You can display the bitmap so that its colors are remapped to
  40. //  the existing palette.
  41.  
  42. display bitmap my_bitmap mode DISPLAY_REMAP
  43.  
  44. // Otherwise you can remap the colors of the bitmap to the
  45. //  existing graphics window palette and then display the bitmap
  46. //  without any mapping. This is faster when you need to
  47. //  display the bitmap more than once
  48.  
  49. remap bitmap my_bitmap
  50. display bitmap my_bitmap mode DISPLAY_DIRECT
  51.  
  52. // If you display a bitmap during a multimedia presentation and
  53. //  you need integration with the palette management system then
  54. //  the following statement will allocate colors before it remaps
  55. //  and displays the bitmap.
  56.  
  57. project bitmap my_bitmap
  58.  
  59. // Later you may need to deallocate the palette colors used by
  60. //  this bitmap. The following instruction will release all colors
  61. //  used by every bitmap displayed by this script
  62.  
  63. decompose
  64.  
  65. //////////////////////////////
  66. // (3) - Pixels
  67.  
  68. // The color of each pixel in a bitmap can be found by treating
  69. //  the bitmap as an array of the form [xmax][ymax][3]
  70.  
  71. message "The red, green and blue values of the first pixel are "
  72. message my_bitmap[0][0][0],", ",my_bitmap[0][0][1],", ",my_bitmap[0][0][2]
  73.  
  74. // Colors may also be assigned new red, green or blue values
  75.  
  76. my_bitmap[0][0][0] = 255, 255, 255
  77.  
  78.